
#include <memory>
using std::shared_ptr;

class B {
protected:
    B() {}
    virtual void PostInitialize(){}
public:
    template<class T>
    static shared_ptr<T> Create() {
        shared_ptr<T> p(new T);
        p->PostInitialize();
        return p;
    }
};

class D :public B{};

int main()
{
    shared_ptr<D> pD = D::Create<D>();
    return 0;
}
